7. Vulnerability Analysis

It is part of Scanning phase.
It is the process of identifying and assessing vulnerabilities on a target system.
It means discovering weaknesses like buffer overflow, vulnerable services.


Vulnerability Scoring Systems
A way to rank or categorise vulnerabilities based on their severity.

  1. Common Vulnerability Scoring Systems(CVSS)
    Numeric score based on principal characteristics of vulnerability.
    https://www.frst.org

d7b965219d5a7127e6ee9bbfc3cf91e7.png

  1. Common Vulnerabilities and Exposure (CVE)
    It maintains the list of known vulnerabilities including an identification number and description.
    https://cve.mitre.org

Exploit and Vulnerability Databases
After scanning a host we can search here for potential exploits and vulnerabilities for the services running on the host.

  1. cvedetails.com – search for vulnerability, exploits and metasploit modules
  2. exploit-db – Exploit Database by Offensive Security
  3. Searchsploit – an offline exploit searching tool based on exploit-db
  4. securityfocus.com – search for exploit, vulnerability and solutions
  5. CVSS and CVE sites – search for vulnerabilities and their severity

Note: Exploits are not always reliable and be sure to check the code before executing one. As they may contain malicious encoded shell codes which may harm your system, privacy or integrity.


Vulnerability scanners


Nmap Vuln Scripts
NSE scripts are defined based on a list of predefined categories where each script belongs. These categories include: brute, default, discovery, dos, exploit, fuzzer, intrusive, malware, vuln etc.

a31e77d323e8e66dfc579e92c57bb41f.png
Vuln scripts allows us to scan for vulnerabilities on a host or network using nmap.
The scan can take some time depending on the target.

Syntax:

nmap --script vuln [TARGET]

Use -d (debug) option to get more information on scripts working and what Nmap is doing and why or if there’s a bug. It is mostly useful for developers.
You can also use verbose (-v).

Note: It will get noisy ;)

Scanning Metasploitable2 with nmap vuln

e8ca5db27da5c2333c886c435c716b13.png

Above nmap has done a bit more than just scanning for vulnerability, it has also provided exploit details and references.

Note: There are many vulnerabilities in Metasploitable2 (every open port is vulnerable)


References in Details

e0df543d6a7d931b09d0931705c52a4e.png

6573a14fe3cb78cfddd35a55b2961348.png

3e03a152c160f852c75eb0a693032a9f.png

Also check out solution and references tab.

e26ac5e739d65450c755f85e221da07b.png

2b569966c935a25e323fbe083ac15f05.png

Note: NVD is official site of US govt and is not trustworthy, it does not list all the information.


Scanning Specific ports for Vulnerability

2ef5e1e13b5b9cf32e4f0cd5a1b1b3ea.png
Above we can see nmap tries different scripts on each port to know if specific vulnerability is present or not.


Exporting scan results

eb7da9e243bfb34a6616b06b90a170a6.png

sudo nmap -O --script vuln exploit -oX scan_results.xml -d 192.168.56.3

Command Breakdown:
-O - perform OS detection
--script vuln exploit- executing scripts in vuln and exploit categories against the target ,scripts for vulnerability analysis and exploitation

Note: scripts in exploit category will try to exploit the vulnerabilities.

-oX [filename.xml] - to export nmap output in xml format for detail analysis later

-d - debug to get more details about the scan

Turn Nmap XML output file into HTML file.

xsltproc [nmap-output-filename.xml]-o [nmap-output-filename.html]

849837b6d47e626217efb7ebde365d12.png

Open this HTML file in browser to read the report,use browser zoom if required

39f6187271635c371e7029be938a2ae3.png

Get more information about a scripts used using --script-help command

894eceee15c31069f16f1cc1180ea7ec.png


Analysis:

nmap --script ftp-vsftpd-backdoor [TARGET]


OpenVAS (Open Vulnerability Assessment System)
It has been merged with GVM (Greenbone Vulnerability Manager) now.

50b2fc4c9f1e277b0c47060968606113.png

An attacker can lookup these vulnerabilities in Metasploit to carry out an attack.

Scanning Metasploitable 2 using OpenVAS

bfabcc3cec84b7c574aa55b662f7686e.png

QoD is the quality of detection, which indicates how sure the scanner is that this vulnerability exists. At 70 percent, there will be some false positives. At 100 percent, the reports will only contain vulnerabilities that were exploited. This can help filter results.

Clicking on a vulnerability will give a summary of the issue detected.

b9748126c556f59616b7014b9314f081.png

3c7b8e701dfddc8983634beeb0406cbc.png

Analysis:


Nessus
It is a proprietary vulnerability scanner developed by Tenable Network Security. It also has a free version.
It requires at least 10-30 Gb free space.

Web interface address: https://localhost:8834/

Scanning Metasploitable 2 with Nessus
(Basic Network Scan)

16b8bc5b10e42d2bc9c1a1a345ec6a54.png

2699dd8813d7e37183da2cd01711c6b5.png

6fc3ecfb0868eda2e6fb7512dab2dd93.png

Export this report in PDF format and then compare and analyse all the 3 reports.


Researching Vulnerabilities

  1. vsftpd 2.3.4
    Search it

ed0d61c625ba252b7ec8bbdc7ecdfcd6.png

Add suffix like exploit or vulnerability for better results.

f327969f48038fc9d8431b15ad3b6d6c.png

Below you can see that a simple search can provide us information like vuln details,cause of vulnerability ,how to exploit it and even the exploit module of Metasploit that can be used.

a0d8b06c64bc58c75c9cb7739da7cc56.png

a41469b417ad9a875a8289fdc4c71f65.png

Exploit-db contains the vulnerable app also,so that we can try the exploit.Make sure to check that exploit is verfied.

  1. UnrealIRCD 3.2.8.1

6612b95cca5f21dfc5a350010d8e7374.png

587c22f41db3606e5a9e50283e975b54.png

37007fdcb99ddfe8ef1bc4b6dd896589.png

Exploit-db search result

26957191d6e831e169292d127997d701.png

After this we simply need to find the proper exploit to take advantage of the vulnerabilities.


Researching Vulnerabilities using Nmap

We will use the vulners script for this purporse.
Vulners is a database of all known vulnerabilities and offers some more features.

af25c1ec67effa79afe03711db9911d9.png

Common Platform Enumeration (CPE) is a standardized way to name software applications, operating systems, and hardware platforms.
Nmap includes CPE output for service and OS detection.

5469e47de407105ab32cf1ac9a6841c4.png

nmap -sV --script vulners [TARGET] -p [PORT]

42e47f04f924ac27705bc2dba84e3a10.png

857d9265c8e02a49c44eb2a5ef86718a.png

To save the output use '>[filenmae].txt' after the -p option.

e0a276b2c0a5d5cedc35789d8eb2a3f6.png

Note: This script does not confirm the existenece of the vulnerabiliy, it only provides link to the known vulnerabilites based on the service or software version.